package com.wzm.moviepic.fragment;

import java.util.ArrayList;

import net.tsz.afinal.FinalBitmap;

import com.wzm.bean.HistoryBean;
import com.wzm.bean.MovieInfo;
import com.wzm.manager.AppManager;
import com.wzm.moviepic.R;
import com.wzm.utils.Logger;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class HistoryAdapter extends BaseAdapter {
	
	private ArrayList<HistoryBean> mList = null;
	private Context mContext = null;
	private LayoutInflater  mInflater;
	HistoryAdapter(Context context,ArrayList<HistoryBean> list)
	{
		
		mContext = context;
		mList = list;
		mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);		
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return mList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View view = convertView;
		ViewHolder viewHolder = null;
		if(view == null)
		{
			view = mInflater.inflate(R.layout.history_item, parent, false);   
			viewHolder = new ViewHolder();			
			viewHolder.movie_name = (TextView)view.findViewById(R.id.movie_name);	
			viewHolder.movie_addtime = (TextView)view.findViewById(R.id.movie_addtime);
			viewHolder.movie_rate = (TextView)view.findViewById(R.id.movie_rate);
			view.setTag(viewHolder);
		}else{
			viewHolder = (ViewHolder) view.getTag();
		}
		final HistoryBean mi = mList.get(position);
		viewHolder.movie_name.setText(mi.getMoviename());
		viewHolder.movie_addtime.setText(mi.getAddtime());
		viewHolder.movie_rate.setText("("+mi.getMark()+"/"+mi.getSize()+")");
		return view;
	}
	
	
	
	private class ViewHolder {
        public TextView movie_name;    
        public TextView movie_addtime;
        public TextView movie_rate;
    };

}
